package com.csdj.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/** * @program: VehicleManageHD
 * @description:
 * @author: 大臣
 * @create: 2024-11-17 20:01
 **/

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private int code;
    private String msg;
    private T data;

    public static <T> Result<T> success() {
        return new Result<T>(200, "success", null);
    }

    public static <T> Result<T> success(T data) {
        return new Result<T>(200, "success", data);
    }

    public static <T> Result<T> success(T data, String msg) {
        return new Result<T>(200, msg, data);
    }

    public static <T> Result<T> success(String msg ) {
        return new Result<T>(200, msg, null);
    }

    public static<T> Result<T> fail(){
        return new Result<>(20001,"fail",null);
    }

    public static<T> Result<T> fail(Integer code){
        return new Result<>(code,"fail",null);
    }

    public static<T> Result<T> fail(Integer code, String message){
        return new Result<>(code,message,null);
    }

    public static<T> Result<T> fail(String message){
        return new Result<>(20001,message,null);
    }
}
